package mn.usi.spendcontrol.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.Widget;

public class Menu extends Composite {
/*	@UiField MenuBar menuBar;
	@UiField MenuItem InboxMenuItem;
	@UiField MenuItem InvoiceMenuItem;
	@UiField MenuItem PartnerMenuItem;
	@UiField MenuItem PaymentMenuItem;
	@UiField MenuItem BudgetMenuItem;
*/
	private static MenuUiBinder uiBinder = GWT.create(MenuUiBinder.class);

	interface MenuUiBinder extends UiBinder<Widget, Menu> {
	}

	public Menu() {
		initWidget(uiBinder.createAndBindUi(this));
		
		/*/ insert a separator
	    menuBar.insertSeparator(1);
	    // attach commands to a menu item
	   InboxMenuItem.setCommand(new MenuCommand(HistoryToken.Inbox));
	   InvoiceMenuItem.setCommand(new MenuCommand(HistoryToken.Invoice));
	   PartnerMenuItem.setCommand(new MenuCommand(HistoryToken.Partner));
	   PaymentMenuItem.setCommand(new MenuCommand(HistoryToken.Payment));
	   BudgetMenuItem.setCommand(new MenuCommand(HistoryToken.Budget));

	}
	
	public class MenuCommand implements Command {
	    final HistoryToken historyToken;

	    public MenuCommand(HistoryToken historyToken) {
	        this.historyToken = historyToken;
	    }

	    @Override
	    public void execute() {
	        historyToken.fire();
	    }
	}  

	public enum HistoryToken {
	    Inbox, Invoice, Partner, Payment, Budget;

	    public void fire(){
	        History.newItem(this.toString());
	    }*/
	}

}
